package com.resource.project.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.resource.project.entity.RespBean;
import com.resource.project.entity.TResourceManage;
import com.resource.project.service.ITResourceManageService;
import com.resource.util.page.PageParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 领料/入库单表 前端控制器
 * </p>
 *
 * @author resource
 * @since 2020-12-08
 */
@RestController
@RequestMapping("/project/t-resource-manage")
public class TResourceManageController {
    @Autowired
    private ITResourceManageService resourceManageService;
    @ApiOperation(value = "领料单/入库单分页")
    @PostMapping
    public IPage<TResourceManage> page(PageParam pageParam, @RequestBody TResourceManage resource){
        return resourceManageService.page(pageParam,resource);
    }

    @ApiOperation(value = "添加申请单")
    @PostMapping("/add")
    public RespBean add(@RequestBody TResourceManage resource){
        return resourceManageService.add(resource);
    }

    @ApiOperation(value = "审批通过")
    @GetMapping("/approve/{id}")
    public RespBean approve(@PathVariable Long id){
        return resourceManageService.approve(id,true);
    }

    @ApiOperation(value = "审批驳回")
    @GetMapping("/reject/{id}")
    public RespBean reject(@PathVariable Long id){
        return resourceManageService.approve(id,false);
    }

}
